unit rpGaranti;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uClassReport, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  cxPCdxBarPopupMenu, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage,
  Data.DB, cxDBData, Vcl.Menus, Data.Win.ADODB, Vcl.ImgList, Vcl.ActnList,
  cxPropertiesStore, Vcl.StdCtrls, cxButtons, cxGridLevel, cxClasses,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, cxPC, cxGroupBox, cxDropDownEdit, cxCalendar, cxTextEdit, cxMaskEdit,
  cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, cxHeader, cxCheckBox;

type
  TfmrpGaranti = class(TfmClassReport)
    Label6: TLabel;
    lcActionGrupList: TcxLookupComboBox;
    Label1: TLabel;
    Label2: TLabel;
    edBitTarih: TcxDateEdit;
    edBasTarih: TcxDateEdit;
    aqActionList: TADOQuery;
    dsActionList: TDataSource;
    grdReportsGarantiNo: TcxGridDBColumn;
    grdReportdteBelgeOnayTrh: TcxGridDBColumn;
    grdReportsUnvan: TcxGridDBColumn;
    grdReportsSehir: TcxGridDBColumn;
    grdReportsCinsi: TcxGridDBColumn;
    grdReportsMarka: TcxGridDBColumn;
    grdReportsGarantiSure: TcxGridDBColumn;
    grdReportsDurumu: TcxGridDBColumn;
    grdReportdteBelgeGecTrh: TcxGridDBColumn;
    grdReportdteBelgeYenTrh: TcxGridDBColumn;
    grdReportsAdres: TcxGridDBColumn;
    grdReportsModelAd: TcxGridDBColumn;
    grdReportsAltModelAd: TcxGridDBColumn;
    grdReportsActionGrup: TcxGridDBColumn;
    cbYururluk: TcxCheckBox;
    grdReportsDurumu2: TcxGridDBColumn;
    Label8: TLabel;
    edAnaFirma: TcxTextEdit;
    grdReportBolge: TcxGridDBColumn;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure acListExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmrpGaranti: TfmrpGaranti;

implementation

{$R *.dfm}

procedure TfmrpGaranti.acListExecute(Sender: TObject);
var
  ExCursor: TCursor;
begin
  inherited;
  ExCursor := Screen.Cursor;
  Screen.Cursor := crSQLWait;
  try
    with aqList do
    begin
      Close;
      SQL.Text := 'EXEC SP_GARANTI @ActionGrup=:ActionGrup,@BasTarih=:BasTarih,@BitTarih=:BitTarih,@Yururluk=:Yururluk,@AnaFirma=:AnaFirma';

      if Trim(lcActionGrupList.Text) = '' then
        Parameters.ParamByName('ActionGrup').Value := NULL
      else
        Parameters.ParamByName('ActionGrup').Value := lcActionGrupList.EditValue;

      if (edBasTarih.Text = '') then
      begin
        Parameters.ParamByName('BasTarih').Value := NULL;
      end
      else
      begin
        Parameters.ParamByName('BasTarih').Value := edBasTarih.Date;
      end;

      if (edBitTarih.Text = '') then
      begin
        Parameters.ParamByName('BitTarih').Value := NULL;
      end
      else
      begin
        Parameters.ParamByName('BitTarih').Value := edBitTarih.Date;
      end;

      Parameters.ParamByName('Yururluk').Value := cbYururluk.Checked;
      Parameters.ParamByName('AnaFirma').Value := edAnaFirma.Text;
      Open;
    end;
  finally
    Screen.Cursor := ExCursor;
  end;
end;

procedure TfmrpGaranti.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmrpGaranti := nil;
end;

procedure TfmrpGaranti.FormCreate(Sender: TObject);
begin
  inherited;
  aqActionList.Close;
  aqActionList.Open;
end;

end.
